import { axios } from '@/utils/request'

/**
 * api接口列表
 */
const api = {
  list: '/order/list',
  detail: '/order/detail',
  setMerchantRemark: '/order.event/setMerchantRemark',
  getDeliveryOrder: '/order.event/getDeliveryOrder',
  setCombination: '/order.event/setCombination',
  updateCombination: '/order.event/updateCombination',
  getPreCombOrder: '/order.event/getPreCombOrder',
  getCombOrder: '/order.event/getCombOrder',
  create: '/logistics/create',
  check: '/logistics/check',
  download: '/logistics/download',
  cancel: '/logistics/cancel',
  batchDelivery: '/order.event/batchDelivery'
}

// 列表记录
export function list(params) {
  return axios({
    url: api.list,
    method: 'get',
    params
  })
}

// 订单详情
export function detail(params) {
  return axios({
    url: api.detail,
    method: 'get',
    params
  })
}

// 订单导出
export function exports(params) {
  return axios({
    url: api.detail,
    method: 'get',
    params
  })
}

// 批量发货模板
export function deliveryTpl(params) {
  return axios({
    url: api.deliveryTpl,
    method: 'get',
    params
  })
}

/**
 * 获取未发货订单（可组合的）
 * @param {*} data
 */
export function getDeliveryOrder() {
  return axios({
    url: api.getDeliveryOrder,
    method: 'get'
  })
}

/**
 * 设置组合订单
 * @param {*} data
 */
export function setCombination(data) {
  return axios({
    url: api.setCombination,
    method: 'post',
    data: data
  })
}

/**
 * 设置/移除组合订单
 * @param {*} data
 */
export function updateCombination(data) {
  return axios({
    url: api.updateCombination,
    method: 'post',
    data: data
  })
}


/**
 * 获取可组合订单
 * @param {*} data
 */
export function getPreCombOrder(params) {
  return axios({
    url: api.getPreCombOrder,
    method: 'get',
    params
  })
}

/**
 * 获取已组合订单
 * @param {*} data
 */
export function getCombOrder() {
  return axios({
    url: api.getCombOrder,
    method: 'get'
  })
}

/**
 * 运单申请
 * @param {*} data
 */
export function getCreate(params) {
  return axios({
    url: api.create,
    method: 'get',
    params
  })
}

/**
 * 批量发货
 * @param data
 * @returns {AxiosPromise}
 */
export function batchDelivery(data) {
  return axios({
    url: api.batchDelivery,
    method: 'post',
    data
  })
}


/**
 * 查询运单生成结果:
 * @param {*} data
 */
export function getCheck(params) {
  return axios({
    url: api.check,
    method: 'get',
    params
  })
}


/**
 * 运单打印下载
 * @param {*} data
 */
export function getDownload(params) {
  return axios({
    url: api.download,
    method: 'get',
    params
  })
}

/**
 * 运单取消
 * @param {*} data
 */
export function getCancel(params) {
  return axios({
    url: api.cancel,
    method: 'get',
    params
  })
}



